@echo off
chcp 65001 >nul
REM KWDB Import Tool Build Script
REM Requires Go 1.18 or higher

echo Checking Go environment...
go version
if %errorlevel% neq 0 (
    echo Error: Go not found, please install Go 1.18 or higher
    echo Download: https://golang.org/dl/
    pause
    exit /b 1
)

echo.
echo Downloading dependencies...
go mod download
if %errorlevel% neq 0 (
    echo Error: Failed to download dependencies
    pause
    exit /b 1
)

echo.

echo Building project...
go build -o bin/kwdb-import.exe ./cmd/kwdb-import
if %errorlevel% neq 0 (
    echo Error: Build failed
    pause
    exit /b 1
)

echo.
echo Build completed successfully!
echo Executable: bin/kwdb-import.exe
echo.
echo Usage:
echo   bin\kwdb-import.exe --help
echo   bin\kwdb-import.exe version
echo   bin\kwdb-import.exe config init config.yaml
echo   bin\kwdb-import.exe validate config.yaml
echo   bin\kwdb-import.exe input.sql --config config.yaml 
echo   bin\kwdb-import.exe input.sql --config config.yaml --dry-run 
echo.
pause